import { Redirect, IRouteComponentProps } from 'umi';
// import {menus} from "../pages/home/components/Menu";

export default (props: IRouteComponentProps) => {
  const token = localStorage.getItem('token');
  // props.location.pathname
  // 通过当前的pathname的值，去匹配对应的哪个menu，找到对应的menu的权限
  // menu的权限有没有在这个用户的auth数组里面
  if (token) {
    return <div>{props.children}</div>;
  } else {
    return <Redirect to="/login" />;
  }
};
